package com.awesome.kotlindemo.function.extend

import android.text.Editable
import android.text.TextWatcher
import android.widget.TextView

/**
 * Author: zhangjingfang
 * Email:zhangjingfang@jeejio.com
 * Date: 2021/11/25
 * Description:类描述
 */
fun TextView.addTextChangedListener(onTextChanged: (s: CharSequence?) -> Unit) {
    addTextChangedListener(object : TextWatcher {
        override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
        }

        override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
            onTextChanged(s)
        }

        override fun afterTextChanged(s: Editable?) {
        }
    })
}